package com.cos.mp.lession69.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Date;

/**
 * @author: COS
 * @time: 2021/12/2 9:14
 * @description:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@TableName(value = "tb_user") //设置实体类和数据库表的映射 value=>表名
public class TbUser {
    @TableId(type= IdType.AUTO)
    private Integer id;
    /**
     * @author: COS
     * @description: 设置实体类属性和数据库字段的映射 value 设置该属性对应的数据库字段名
     * 字段值（驼峰命名方式，该值可无）
     */
    @TableField(value = "user_name")
    private String userName;
    private String password;
    private String name;
    private Integer age;
    /**
     *
     * @author: COS
     * @description: 是否进行 select 查询 默认true
     */
//    @TableField(select = false)
    private String email;
    @TableField(value = "bornDate")
    private Date bornDate;
    /**
     *
     * @author: COS
     * @description:  是否为数据库表字段 默认true
     */
    @TableField(exist = false)
    private Dept dept;

    public TbUser(String userName, String password, String name, int age, String email, Date bornDate) {
        this.userName = userName;
        this.password = password;
        this.name = name;
        this.age = age;
        this.email = email;
        this.bornDate = bornDate;
    }

    public TbUser(Integer id, String userName, String password, String name, int age, String email, Date bornDate) {
        this.id = id;
        this.userName = userName;
        this.password = password;
        this.name = name;
        this.age = age;
        this.email = email;
        this.bornDate = bornDate;
    }

    public TbUser(String userName, String password, String name, int age, String email, Date bornDate, Dept dept) {
        this.userName = userName;
        this.password = password;
        this.name = name;
        this.age = age;
        this.email = email;
        this.bornDate = bornDate;
        this.dept = dept;
    }
}
